//系统查询   每页显示数据 12     
function js_method() {
	$('#lists').html("");
	loadDataPage("operation/permissions", "srcoll-documentation", "lists", 12,
			"roleName");

}
// 构建数据列表
function dataKk(data, me) {
	var result = '';
	var arrLen = data.length;
	if (arrLen > 0) {
		for (var i = 0; i < arrLen; i++) {
			
	
			
			
			
			
			result += '<a href="#">' + '<li  id=' + data[i].id + '>'
					+ '<div class="spare-new">'
					+ '<div class="spare-newl">用户角色：' + data[i].roleName
					+ '<input type="hidden" id="A'+data[i].id+'" value="'+data[i].roleName+'"></input>'
					+ '</div>' + '</div>' + '<div class="user-new">备注：'
					+ data[i].roleRemark + '</div>'
					+ '<div class="documentation-check"></div>' + '</li>'
					+ '</a>'

		}
	} else {
		me.lock();
		me.noData();
	}
	return result;
}


//授权
function ps(url) {
    if ($('.spare-ara').find('li[class="active"]').length > 1) {
        $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">请选择一条数据</div></div>', {
            'title': '提示',
            'buttons': ['确定']
        });
    } else {
        var id = $('.spare-ara').find('li[class="active"]').attr("id") 
    	$.get(url,{roleId:id}, function(result){
              $("body").html(result);
            
    	  });
    }

}



function loadPageEdit(url) {

    if ($('.spare-ara').find('li[class="active"]').length > 1) {
        $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">请选择一条数据</div></div>', {
            'title': '提示',
            'buttons': ['确定']
        });

    } else {
        var id = $('.spare-ara').find('li[class="active"]').attr("id") 
        
        var roleName=$('#A'+id).val();
   
        if(roleName=="系统管理员"||roleName=="审计管理员"||roleName=="superadmin"){
            $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">内置数据不可修改</div></div>', {
                'title': '提示',
                'buttons': ['确定']
            });
            
            return;
        }
        
    	$.post(url,{id:id}, function(result){
    		  $("body").html(result);
    	  });
    }

}

function loadPageDele(url, page) {


    if ($('.spare-ara').find('li[class="active"]').length < 0) {
        $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">请选择一条数据</div></div>', {
            'title': '提示',
            'buttons': ['确定']
        });

    } else {
  
    	
    	
    	
    	
        var ids = $('.spare-ara').find('li[class="active"]');
        var id = "";
        for (var i = 0; i < ids.length; i++) {
        	
        var  idyz=$(ids[i]).attr("id");
            if (i < ids.length - 1) {
                id += $(ids[i]).attr("id") + ",";
                
            } else {
                id += $(ids[i]).attr("id");
            }
            
            
            var roleName=$('#A'+idyz).val();
            
            if(roleName=="系统管理员"||roleName=="审计管理员"||roleName=="superadmin"){
                $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">内置数据不可删除</div></div>', {
                    'title': '提示',
                    'buttons': ['确定']
                });
                
                return;
            }
        	
            
        }

        $.ajax({
            type: "post",
            dataType: "json",
            url: url,
            data: {
                id: id
            },
            success: function(data, status) {

                $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">删除成功</div></div>', {
                    'title': '提示',
                    'show_close_button': false,
                    'buttons': [{
                        caption: '确定',
                        callback: function() {
                        	loadPage(page);

                        }
                    }]
                });
            
            },
            error: function(data) {
                $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">删除失败</div></div>', {
                    'title': '提示',
                    'show_close_button': false,
                    'buttons': [{
                        caption: '确定',
                        callback: function() {
                            window.location.href = page

                        }
                    }]
                });
            }
        });

    }
}

